package dados;

import java.util.Timer;
import java.util.TimerTask;

public class Cooldown {
	
	    private boolean valid;
	    private Timer timer;
	    private long delay = 500;
	    private static Cooldown instance = null;

	    public static Cooldown getSharedInstance() {
	        if (instance == null) {
	            instance = new Cooldown();
	        }
	        return instance;
	    }

	    private Cooldown() {
	        timer = new Timer();
	        valid = true;
	    }

	    public boolean checkValidity() {
	        if (valid) {
	            valid = false;
	            timer.schedule(new Task(), delay);
	            return true;
	        }
	        return false;
	    }

	    class Task extends TimerTask {

	        public void run() {
	            valid = true;
	        }

	    }
	}


